home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Applications / MakeFat 1.0 / PNL Libraries / MyVersionResource.p < prev    next >
Encoding:
Text File  |  1995-11-16  |  1.5 KB  |  69 lines  |  [TEXT/CWIE]

  1. unit MyVersionResource;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types;
  7.  
  8.     type
  9.         versionRecord = packed record
  10.                 numericVersion: NumVersion;
  11.                 countryCode: integer;
  12.                 shortVersion: str15;
  13.                 longVersion: Str255;
  14.                 name: str63;
  15.             end;
  16.  
  17.     procedure GetVersion (var vers: versionRecord);
  18.     procedure SetVersionParamText (c3: Str255);
  19.  
  20. implementation
  21.  
  22.     uses
  23.         Resources, Memory, Dialogs, MyStrings;
  24.  
  25.     procedure GetVersion (var vers: versionRecord);
  26.         var
  27.             vh: handle;
  28.             p: integer;
  29.     begin
  30.         with vers do begin
  31.             vh := GetResource('vers', 1);
  32.             if vh = nil then begin
  33.                 longint(numericVersion) := $00002000;
  34.                 countryCode := 0;
  35.                 shortVersion := '0.0.0';
  36.                 longVersion := 'Unknown v0.0.0';
  37.                 name := 'Unknown';
  38.             end else begin
  39.                 BlockMoveData(vh^, @vers, sizeof(vers));
  40.                 BlockMoveData(Ptr(longint(vh^) + (longint(@shortVersion) - longint(@vers)) + length(shortVersion) + 1), @longVersion, sizeof(longVersion));
  41.                 if length(shortVersion) >= sizeof(shortVersion) then begin
  42. {$PUSH}
  43.  {$R-}
  44.                     shortVersion[0] := chr(sizeof(shortVersion) - 1);
  45. {$POP}
  46.                 end;
  47.                 ReleaseResource(vh);
  48.             end;
  49.             p := TPPos(shortVersion, longVersion);
  50.             while (p > 0) & (vers.longVersion[p] <> ' ') do begin
  51.                 p := p - 1;
  52.             end;
  53.             p := p - 1;
  54.             if p < 1 then begin
  55.                 p := 255;
  56.             end;
  57.             name := TPcopy(vers.longVersion, 1, p);
  58.         end;
  59.     end;
  60.  
  61.     procedure SetVersionParamText (c3: Str255);
  62.         var
  63.             vers: versionRecord;
  64.     begin
  65.         GetVersion(vers);
  66.         ParamText(vers.shortVersion, vers.longVersion, vers.name, c3);
  67.     end;
  68.  
  69. end.